package com.lagou.controller;

import com.lagou.domain.EmpWithDept;
import com.lagou.service.EmpWithDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/empWithDept")
public class EmpWithDeptController {

    @Autowired
    private EmpWithDeptService empWithDeptService;

    @RequestMapping("/findAll")
    public String findAll(Model model){
        //  集合中的每个元素除了由员工信息，还有部门名称信息
        List<EmpWithDept> empWithDepts = empWithDeptService.findAll();
        model.addAttribute("list", empWithDepts);
        return "list";
    }
}
